
package view;

import controllers.HelpContentControl;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.VPos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class ExplorerErrorDialog extends CustomizedStage {
    
    private final double minTFWidth=500;

    private GridPane grid;
    private Label messageL;
    private TextField hyperlinkTF;
    private Button okButton;

    public ExplorerErrorDialog(Stage owner) {
        this(owner, 0, 0);
    }

    public ExplorerErrorDialog(Stage owner, double width, double height) {
        super(owner, "Error", width, height);
        setOnClose(HIDE);
        grid=new GridPane();
        grid.setPadding(new Insets(20));
        grid.setVgap(10);
        grid.setId("explorer-error-dialog");
        
        messageL=new Label("Error al abrir un navegador web. Acceda desde: ");
        hyperlinkTF=new TextField(HelpContentControl.URL);
        hyperlinkTF.setMinWidth(minTFWidth);
        hyperlinkTF.setEditable(false);
        hyperlinkTF.setFocusTraversable(false);
        okButton=new Button("Copiar y Cerrar");
        okButton.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                hyperlinkTF.selectAll();
                hyperlinkTF.copy();
                close();
            }
        });
        GridPane.setConstraints(messageL, 0, 0);
        GridPane.setConstraints(hyperlinkTF, 0, 1);
        GridPane.setConstraints(okButton, 0, 2, 1, 1, HPos.RIGHT, VPos.CENTER);
        grid.getChildren().addAll(messageL,hyperlinkTF,okButton);
        setContent(grid);
    }
    
}